package cn.zzu.Etrip.hometrip.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

import com.example.administrator.etrip.MainActivity;
import com.example.administrator.etrip.R;

import cn.zzu.Etrip.hometrip.service.DataUtil;
import cn.zzu.Etrip.twoday.activity.TwoDayPayActivity;

/**
 * Created by ASUS on 2018/5/23.
 */
public class HomeTripActivity extends AppCompatActivity {
    private Button search_btn,location_btn;
    private EditText text;
    public void onCreate(Bundle saveInstanceState){
        super.onCreate(saveInstanceState);
        setContentView(R.layout.familytrip);
        search_btn = findViewById(R.id.btn_search);
        location_btn = findViewById(R.id.et_location);
        text = findViewById(R.id.et_1);
        search_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(HomeTripActivity.this,HomeTripHotelActivity.class);
                intent.putExtra("text",text.getText().toString());
                startActivity(intent);

            }
        });
        location_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String items[] = {"上海", "北京", "郑州","深圳", "广州", "悉尼","三亚", "商丘", "重庆"};
                AlertDialog.Builder builder = new AlertDialog.Builder(HomeTripActivity.this,0);
                builder.setTitle("单选");
                builder.setIcon(R.mipmap.ic_launcher);
                builder.setSingleChoiceItems(items, 0,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                                text.setText(items[which]);
                                Toast.makeText(HomeTripActivity.this, items[which],
                                        Toast.LENGTH_SHORT).show();
                            }
                        });
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        Toast.makeText(HomeTripActivity.this, "确定", Toast.LENGTH_SHORT)
                                .show();
                    }
                });
                builder.create().show();

            }
        });
        ImageView im1,im2,im3,im4,im5;
        im1=findViewById(R.id.iv_sc_1);
        im2=findViewById(R.id.iv_sc_2);
        im3=findViewById(R.id.iv_sc_3);
        im4=findViewById(R.id.iv_sc_4);
        im5=findViewById(R.id.iv_sc_5);

        View.OnClickListener mm=new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(HomeTripActivity.this,HomeTripHotelActivity.class);
                intent.putExtra("text",text.getText().toString());
                switch(v.getId()){
                    case R.id.iv_sc_1:
                        intent.putExtra("city1",new DataUtil().a1);
                        intent.putExtra("price1",new DataUtil().price1);
                        intent.putExtra("desc1",new DataUtil().desc1);
                        break;
                    case R.id.iv_sc_2:
                        intent.putExtra("city1",new DataUtil().a2);
                        intent.putExtra("price1",new DataUtil().price2);
                        intent.putExtra("desc1",new DataUtil().desc2);
                        break;
                    case R.id.iv_sc_3:
                        intent.putExtra("city1",new DataUtil().a3);
                        intent.putExtra("price1",new DataUtil().price3);
                        intent.putExtra("desc1",new DataUtil().desc3);
                        break;
                    case R.id.iv_sc_4:
                        intent.putExtra("city1",new DataUtil().a4);
                        intent.putExtra("price1",new DataUtil().price4);
                        intent.putExtra("desc1",new DataUtil().desc4);
                        break;
                    case R.id.iv_sc_5:
                        intent.putExtra("city1",new DataUtil().a5);
                        intent.putExtra("price1",new DataUtil().price5);
                        intent.putExtra("desc1",new DataUtil().desc5);
                        break;
                }
                startActivity(intent);
            }
        };
        im1.setOnClickListener(mm);
        im2.setOnClickListener(mm);
        im3.setOnClickListener(mm);
        im4.setOnClickListener(mm);
        im5.setOnClickListener(mm);

    }
}
